package com.scuec.tourismwebsite.mapper;


import com.scuec.tourismwebsite.vo.PopularityAttraction;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface AttractionPopularityMapper {

    @Select("SELECT Tourist_Attraction.attraction_name,Attraction_Popularity.click_count,Attraction_Popularity.last_update_date " +
            "FROM Attraction_Popularity JOIN Tourist_Attraction " +
            "ON Attraction_Popularity.attraction_id = Tourist_Attraction.attraction_id")
    List<PopularityAttraction> getAllAttractionPopularity();


    @Delete("delete from Attraction_Popularity where popularity_id=#{popularity_id}")
    int deleteAttractionPopularityById(int popularity_id);

    @Select("SELECT Tourist_Attraction.attraction_name,Attraction_Popularity.click_count,Attraction_Popularity.last_update_date " +
            "FROM Tourist_Attraction JOIN Attraction_Popularity " +
            "ON Tourist_Attraction.attraction_id=Attraction_Popularity.attraction_id WHERE Tourist_Attraction.attraction_name LIKE CONCAT('%', #{attraction_name}, '%')")
    List<PopularityAttraction> findAttractionByName(String attraction_name);
}
